const { tool,api } = getApp();
Page({

    data: {
        info: {},   // 用户信息
        funs: [
            {
                title: '学生',
                list: [
                    { id: 1,title: '我的信息', icon: '/assets/icon/fun_0.png' },
                    { id: 2,title: '我的课题', icon: '/assets/icon/fun_1.png' },
                ]
            },
            {
                title: '周报',
                list: [
                    { id: 4,title: '我的周报', icon: '/assets/icon/fun_3.png' },
                    { id: 5,title: '写周报', icon: '/assets/icon/fun_4.png' },
                ]
            },
            {
                title: '系统',
                list: [
                    { id: 6,title: '文件上传', icon: '/assets/icon/fun_5.png' },
                    // { id: 7,title: '使用说明', icon: '/assets/icon/fun_6.png' },
                    { id: 7,title: '清除缓存', icon: '/assets/icon/fun_7.png' },
                ]
            }
        ]
    },

    // 使用方法
    click(e) {
        let { id } = e.currentTarget.dataset;
        let { open_id } = this.data.info;
        let path = '/pages/user/';
        switch (id) {
            case 1: path += `info/index?id=${open_id}`; break;
            case 2: path += `class/index?id=${open_id}`; break;
            case 3: path += `group/index?id=${open_id}`; break;
            case 4: path += `report/list/index?id=${open_id}`; break;
            case 5: path += `report/add/index?id=${open_id}`; break;
            case 6: path += `agree/index?id=${open_id}`; break;
            case 7: path += `manual/index?id=${open_id}`; break;
            case 8:
                api.clearStorage();
                api.showModal('提示','缓存清除成功，请重新登录',false).then(res => {
                    api.navigateTo('/pages/user/login/index');
                }); break;
        }
        if (id != 8) api.navigateTo(path);
    },

    // 页面加载
    onShow() {
        tool.getUserInfo().then(info => {
            this.setData({ info });
        })
    },
    
})